﻿using System.Linq;
using Sidvall.Collections;

namespace Sidvall.WorkItemManager.UI.Entities
{
    public sealed partial class WorkItemCollection : Sidvall.WorkItemManager.UI.Entities.Core.BusinessBaseCollection<WorkItem>
    {
        #region Public Members
        
        #region LoadWorkItemLogsAsync

        public async System.Threading.Tasks.Task LoadWorkItemLogsAsync()
        {
            await LoadWorkItemLogsAsync(false, false, null, null, null);
        }
        public async System.Threading.Tasks.Task LoadWorkItemLogsAsync(bool refresh, bool raisePropertyChanged, global::Sidvall.Data.FetchListCriteria<global::Sidvall.WorkItemManager.Data.Fields.WorkItemLogField, global::Sidvall.WorkItemManager.Data.Relations.WorkItemLogRelation> criteria, string strategyContext, global::Sidvall.Data.ObjectParameterCollection objectParameters)
        {
            await global::Sidvall.WorkItemManager.UI.SystemContext.Current.DataPortal.WorkItemManager.LoadWorkItemLogsAsync(this, refresh, raisePropertyChanged, criteria, strategyContext, objectParameters);
        }

        #endregion
        #region LoadWorkItemSensorsAsync

        public async System.Threading.Tasks.Task LoadWorkItemSensorsAsync()
        {
            await LoadWorkItemSensorsAsync(false, false, null, null, null);
        }
        public async System.Threading.Tasks.Task LoadWorkItemSensorsAsync(bool refresh, bool raisePropertyChanged, global::Sidvall.Data.FetchListCriteria<global::Sidvall.WorkItemManager.Data.Fields.WorkItemSensorField, global::Sidvall.WorkItemManager.Data.Relations.WorkItemSensorRelation> criteria, string strategyContext, global::Sidvall.Data.ObjectParameterCollection objectParameters)
        {
            await global::Sidvall.WorkItemManager.UI.SystemContext.Current.DataPortal.WorkItemManager.LoadWorkItemSensorsAsync(this, refresh, raisePropertyChanged, criteria, strategyContext, objectParameters);
        }

        #endregion
        #region LoadWorkItemWorkConditionsAsync

        public async System.Threading.Tasks.Task LoadWorkItemWorkConditionsAsync()
        {
            await LoadWorkItemWorkConditionsAsync(false, false, null, null, null);
        }
        public async System.Threading.Tasks.Task LoadWorkItemWorkConditionsAsync(bool refresh, bool raisePropertyChanged, global::Sidvall.Data.FetchListCriteria<global::Sidvall.WorkItemManager.Data.Fields.WorkItemWorkConditionField, global::Sidvall.WorkItemManager.Data.Relations.WorkItemWorkConditionRelation> criteria, string strategyContext, global::Sidvall.Data.ObjectParameterCollection objectParameters)
        {
            await global::Sidvall.WorkItemManager.UI.SystemContext.Current.DataPortal.WorkItemManager.LoadWorkItemWorkConditionsAsync(this, refresh, raisePropertyChanged, criteria, strategyContext, objectParameters);
        }

        #endregion
        #region LoadWorkersAsync

        public async System.Threading.Tasks.Task LoadWorkersAsync()
        {
            await LoadWorkersAsync(false, false, null, null, null);
        }
        public async System.Threading.Tasks.Task LoadWorkersAsync(bool refresh, bool raisePropertyChanged, global::Sidvall.Data.FetchListCriteria<global::Sidvall.WorkItemManager.Data.Fields.WorkerField, global::Sidvall.WorkItemManager.Data.Relations.WorkerRelation> criteria, string strategyContext, global::Sidvall.Data.ObjectParameterCollection objectParameters)
        {
            await global::Sidvall.WorkItemManager.UI.SystemContext.Current.DataPortal.WorkItemManager.LoadWorkersAsync(this, refresh, raisePropertyChanged, criteria, strategyContext, objectParameters);
        }

        #endregion
        #region LoadWorkItemTypesAsync

        public async System.Threading.Tasks.Task LoadWorkItemTypesAsync()
        {
            await LoadWorkItemTypesAsync(false, false, null, null, null);
        }
        public async System.Threading.Tasks.Task LoadWorkItemTypesAsync(bool refresh, bool raisePropertyChanged, global::Sidvall.Data.FetchListCriteria<global::Sidvall.WorkItemManager.Data.Fields.WorkItemTypeField, global::Sidvall.WorkItemManager.Data.Relations.WorkItemTypeRelation> criteria, string strategyContext, global::Sidvall.Data.ObjectParameterCollection objectParameters)
        {
            await global::Sidvall.WorkItemManager.UI.SystemContext.Current.DataPortal.WorkItemManager.LoadWorkItemTypesAsync(this, refresh, raisePropertyChanged, criteria, strategyContext, objectParameters);
        }

        #endregion
        #region LoadWorkRetryPoliciesAsync

        public async System.Threading.Tasks.Task LoadWorkRetryPoliciesAsync()
        {
            await LoadWorkRetryPoliciesAsync(false, false, null, null, null);
        }
        public async System.Threading.Tasks.Task LoadWorkRetryPoliciesAsync(bool refresh, bool raisePropertyChanged, global::Sidvall.Data.FetchListCriteria<global::Sidvall.WorkItemManager.Data.Fields.WorkRetryPolicyField, global::Sidvall.WorkItemManager.Data.Relations.WorkRetryPolicyRelation> criteria, string strategyContext, global::Sidvall.Data.ObjectParameterCollection objectParameters)
        {
            await global::Sidvall.WorkItemManager.UI.SystemContext.Current.DataPortal.WorkItemManager.LoadWorkRetryPoliciesAsync(this, refresh, raisePropertyChanged, criteria, strategyContext, objectParameters);
        }

        #endregion
        #region AcceptChanges

        public void AcceptChanges()
        {
            global::Sidvall.WorkItemManager.UI.SystemContext.Current.EntityFacade.WorkItemManager.AcceptChanges(this);
        }

        #endregion
        #region Clone

        public WorkItemCollection Clone()
        {
            var copySettings = Sidvall.Data.CopySettings.Clone();
            return Copy(copySettings);
        }

        #endregion
        #region Copy

        public WorkItemCollection Copy()
        {
            return Copy(null);
        }
        public WorkItemCollection Copy(Sidvall.Data.CopySettings copySettings)
        {
            var items = new WorkItemCollection();
            Import(items, this, copySettings);
            return items;
        }

        #endregion
        #region Import

        public void Import(System.Collections.Generic.IEnumerable<global::Sidvall.WorkItemManager.Data.IWorkItem> items)
        {
            Import(items, null);
        }
        partial void OnAfterImport(System.Collections.Generic.IEnumerable<global::Sidvall.WorkItemManager.Data.IWorkItem> source, Sidvall.Data.CopySettings copySettings);
        public void Import(System.Collections.Generic.IEnumerable<global::Sidvall.WorkItemManager.Data.IWorkItem> items, Sidvall.Data.CopySettings copySettings)
        {
            Import(this, items, copySettings);
        }
        partial void OnAfterImport(WorkItemCollection destination, System.Collections.Generic.IEnumerable<global::Sidvall.WorkItemManager.Data.IWorkItem> source, Sidvall.Data.CopySettings copySettings);
        private void Import(WorkItemCollection destination, System.Collections.Generic.IEnumerable<global::Sidvall.WorkItemManager.Data.IWorkItem> source, Sidvall.Data.CopySettings copySettings)
        {
            global::Sidvall.WorkItemManager.UI.SystemContext.Current.EntityFacade.WorkItemManager.Import(destination, source, copySettings);
            OnAfterImport(destination, source, copySettings);
        }
        partial void OnAfterImport(WorkItemCollection destination, WorkItemCollection source, Sidvall.Data.CopySettings copySettings);
        private void Import(WorkItemCollection destination, WorkItemCollection source, Sidvall.Data.CopySettings copySettings)
        {
            Import(destination, source as System.Collections.Generic.IEnumerable<global::Sidvall.WorkItemManager.Data.IWorkItem>, copySettings);
            OnAfterImport(destination, source, copySettings);
        }

        #endregion
        #region SaveItemsAsync

        public async System.Threading.Tasks.Task<WorkItemCollection> SaveItemsAsync()
        {
            return await global::Sidvall.WorkItemManager.UI.SystemContext.Current.DataPortal.WorkItemManager.SaveItemsAsync(this);
        }
        public async System.Threading.Tasks.Task<WorkItemCollection> SaveItemsAsync(Sidvall.Data.SaveMode mode)
        {
            return await global::Sidvall.WorkItemManager.UI.SystemContext.Current.DataPortal.WorkItemManager.SaveItemsAsync(this, mode);
        }
        public async System.Threading.Tasks.Task<WorkItemCollection> SaveItemsAsync(Sidvall.Data.SaveSettings settings)
        {
            return await global::Sidvall.WorkItemManager.UI.SystemContext.Current.DataPortal.WorkItemManager.SaveItemsAsync(this, settings);
        }

        #endregion
        #region ValidateAsync

        public async System.Threading.Tasks.Task<Sidvall.Data.BusinessRuleCollection> ValidateAsync()
        {
            return await global::Sidvall.WorkItemManager.UI.SystemContext.Current.EntityFacade.WorkItemManager.ValidateAsync(this);
        }
        public async System.Threading.Tasks.Task<Sidvall.Data.BusinessRuleCollection> ValidateAsync(Sidvall.Data.ValidationSettings settings)
        {
            return await global::Sidvall.WorkItemManager.UI.SystemContext.Current.EntityFacade.WorkItemManager.ValidateAsync(this, settings);
        }

        #endregion
        #region Initialize

        public void Initialize()
        {
            global::Sidvall.WorkItemManager.UI.SystemContext.Current.EntityFacade.WorkItemManager.Initialize(this);
        }
        public void Initialize(Sidvall.Data.InitializeSettings settings)
        {
            global::Sidvall.WorkItemManager.UI.SystemContext.Current.EntityFacade.WorkItemManager.Initialize(this, settings);
        }

        #endregion

        #endregion
        #region Constructors

        public WorkItemCollection()
        {
        }

        #endregion
    }
}